#!/bin/bash

echo "~ Now install zsh"

if command -v apt > /dev/null; then
  sudo apt -y install zsh
else
  sudo dnf -y install zsh
fi

rm -rf ~/.oh-my-zsh

# https://ohmyz.sh/#install
until sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"; 
  do sleep 2; 
done

echo "~ Now install zsh plugins"
repo_syntax="https://github.com/zsh-users/zsh-syntax-highlighting.git"
repo_autosuggestions="https://github.com/zsh-users/zsh-autosuggestions"
repo_history_search="https://github.com/zsh-users/zsh-history-substring-search"
if [ -d ~/.ssh ]; then
  repo_syntax="git@github.com:zsh-users/zsh-syntax-highlighting.git"
  repo_autosuggestions="git@github.com:zsh-users/zsh-autosuggestions.git"
  repo_history_search="git@github.com:zsh-users/zsh-history-substring-search.git"
fi
git clone ${repo_syntax} ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone ${repo_autosuggestions} ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone ${repo_history_search} ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search
